//
// Decompiled by Jadx - 439ms
//
package gc;

import a.g;
import a.i;
import android.annotation.SuppressLint;
import android.text.TextUtils;
import fh.b;
import fi.k;
import fn.j;
import fn.x;
import fn.y;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import me.plusne.Adapter.Login.h;
import me.plusne.GreenDao.dao.LookHomeJsonDao;
import me.plusne.common.Json.Soul.JsonHomePagePostList;
import r.f;
import x.d;

public final class ap extends x {

    @SuppressLint({"StaticFieldLeak"})
    public static b cr;
    public static long ct;
    public static long cu;
    public static List<Object> dj;
    public static final ArrayList cp = new ArrayList();
    public static ArrayList cq = new ArrayList();
    public static final int cs = 100;
    public static int cv = 0;
    public static int cw = 0;
    public static int cx = 0;
    public static int cy = 0;
    public static int cz = 0;
    public static int da = 0;
    public static int db = 0;
    public static int dc = 0;
    public static int dd = 0;
    public static int de = 0;
    public static int df = 0;
    public static int dg = 0;
    public static int dh = 0;
    public static int di = 0;

    public static void dk(Map<String, Object> map) {
        try {
            ac.dc("cn.soulapp.android.square.post.api.IPostApi", "NEW_APIA", "getRecommendPosts", new k(7, map), new Object[]{map});
        } catch (Exception e) {
            if (y.ch("autoLikeCheck", false)) {
                cx++;
            }
            if (y.ch("autoReplyCheck", false)) {
                db++;
            }
            y.ch("autoGiftCheck", false);
            if (y.ch("autoBgImgCheck", false)) {
                de++;
            }
            if (y.ch("autoReCallNewsCheck", false)) {
                di++;
            }
            if (y.ch("autoInvitePostCheck", false)) {
                dg++;
            }
            y.ch("autoLoveSpeedCheck", false);
            if (y.ch("autoFollowCheck", false)) {
                cz++;
            }
            e.printStackTrace();
        }
    }

    public static void dl(String str, String str2, int i, boolean z) {
        ac acVar = new ac();
        acVar.dd("https://api-user.soulapp.cn/v2/user/follow/getList?followType=" + i + "&pageCursor=" + str + "&pageSize=100&targetIdEcpt=" + str2);
        acVar.dg(new aj(i, str2, z));
    }

    public static ArrayList dm(long j) {
        LookHomeJsonDao lookHomeJsonDao = y.by.getDb().u;
        lookHomeJsonDao.getClass();
        g gVar = new g(lookHomeJsonDao);
        i.b f = LookHomeJsonDao.Properties.To.f(z.eb());
        d dVar = LookHomeJsonDao.Properties.Id;
        Long valueOf = Long.valueOf(j);
        dVar.getClass();
        gVar.l(f, new i[]{new i.b(dVar, ">?", valueOf)});
        gVar.i(cs);
        return gVar.j();
    }

    public static void dn(long j) {
        String str;
        StringBuilder sb = new StringBuilder("https://api-a.soulapp.cn/meet/see/me/v2?&limit=20&sortType=1");
        if (j > 0) {
            str = androidx.activity.b.f("&lasttime=", j);
        } else {
            str = "";
        }
        sb.append(str);
        String sb2 = sb.toString();
        ac acVar = new ac();
        acVar.dd(sb2);
        acVar.dg(new h(23));
    }

    public static void do(String str, long j, List list, aq aqVar) {
        String str2;
        JsonHomePagePostList jsonHomePagePostList;
        if (list == null) {
            list = new ArrayList();
        }
        ac acVar = new ac();
        StringBuilder sb = new StringBuilder("https://post.soulapp.cn/v5/post/homepage?firstVisitFlag=0");
        if (j > 0) {
            str2 = androidx.activity.b.f("&lastId=", j);
        } else {
            str2 = "";
        }
        sb.append(str2);
        sb.append("&orderType=DESC&userIdEcpt=");
        sb.append(str);
        acVar.dd(sb.toString());
        String dh2 = acVar.dh();
        if (!TextUtils.isEmpty(dh2) && (jsonHomePagePostList = (JsonHomePagePostList) androidx.activity.b.c(dh2, JsonHomePagePostList.class)) != null && jsonHomePagePostList.isSuccess() && jsonHomePagePostList.getData() != null && jsonHomePagePostList.getData().getPostList() != null && !jsonHomePagePostList.getData().getPostList().isEmpty()) {
            JsonHomePagePostList.DataDTO.PostListDTO postListDTO = (JsonHomePagePostList.DataDTO.PostListDTO) jsonHomePagePostList.getData().getPostList().get(0);
            j.bi(new Object[]{postListDTO.getLatitude(), postListDTO.getLongitude()});
            if (postListDTO.getLatitude() != null && postListDTO.getLongitude() != null && postListDTO.getLatitude().doubleValue() != 0.0d && postListDTO.getLongitude().doubleValue() != 0.0d) {
                aqVar.f(postListDTO);
                return;
            } else {
                list.addAll(jsonHomePagePostList.getData().getPostList());
                do(str, ((JsonHomePagePostList.DataDTO.PostListDTO) jsonHomePagePostList.getData().getPostList().get(jsonHomePagePostList.getData().getPostList().size() - 1)).getId(), list, aqVar);
            }
        }
        aqVar.f((JsonHomePagePostList.DataDTO.PostListDTO) null);
    }

    public static List<JsonHomePagePostList.DataDTO.PostListDTO> dp(String str, long j, List<JsonHomePagePostList.DataDTO.PostListDTO> list) {
        String str2;
        JsonHomePagePostList jsonHomePagePostList;
        if (list == null) {
            list = new ArrayList<>();
        }
        ac acVar = new ac();
        StringBuilder sb = new StringBuilder("https://post.soulapp.cn/v5/post/homepage?firstVisitFlag=0");
        if (j > 0) {
            str2 = androidx.activity.b.f("&lastId=", j);
        } else {
            str2 = "";
        }
        sb.append(str2);
        sb.append("&orderType=DESC&userIdEcpt=");
        sb.append(str);
        acVar.dd(sb.toString());
        String dh2 = acVar.dh();
        if (!TextUtils.isEmpty(dh2) && (jsonHomePagePostList = (JsonHomePagePostList) androidx.activity.b.c(dh2, JsonHomePagePostList.class)) != null && jsonHomePagePostList.isSuccess() && jsonHomePagePostList.getData() != null && jsonHomePagePostList.getData().getPostList() != null && !jsonHomePagePostList.getData().getPostList().isEmpty()) {
            list.addAll(jsonHomePagePostList.getData().getPostList());
            dp(str, ((JsonHomePagePostList.DataDTO.PostListDTO) jsonHomePagePostList.getData().getPostList().get(jsonHomePagePostList.getData().getPostList().size() - 1)).getId(), list);
        }
        return list;
    }

    public static void dq(String str, String str2, long j, int i) {
        String str3;
        JsonHomePagePostList jsonHomePagePostList;
        ac acVar = new ac();
        StringBuilder sb = new StringBuilder("https://post.soulapp.cn/v5/post/homepage?firstVisitFlag=0");
        long j2 = 0;
        if (j > 0) {
            str3 = androidx.activity.b.f("&lastId=", j);
        } else {
            str3 = "";
        }
        sb.append(str3);
        sb.append("&orderType=DESC&userIdEcpt=");
        sb.append(str);
        acVar.dd(sb.toString());
        String dh2 = acVar.dh();
        if (!TextUtils.isEmpty(dh2) && (jsonHomePagePostList = (JsonHomePagePostList) androidx.activity.b.c(dh2, JsonHomePagePostList.class)) != null && jsonHomePagePostList.isSuccess() && jsonHomePagePostList.getData() != null && jsonHomePagePostList.getData().getPostList() != null && !jsonHomePagePostList.getData().getPostList().isEmpty()) {
            AtomicInteger atomicInteger = new AtomicInteger();
            for (JsonHomePagePostList.DataDTO.PostListDTO postListDTO : jsonHomePagePostList.getData().getPostList()) {
                j2 = postListDTO.getId();
                if (!Objects.equals(postListDTO.getVisibility(), str2)) {
                    ac acVar2 = new ac();
                    acVar2.de("https://post.soulapp.cn/v3/post/visibility?postId=" + j2 + "&visibility=" + str2, new HashMap(), "POST");
                    String dh3 = acVar2.dh();
                    f i2 = f.i();
                    i2.k();
                    i2.l((atomicInteger.get() + i) + "：" + dh3);
                } else {
                    f i3 = f.i();
                    i3.k();
                    i3.l((atomicInteger.get() + i) + "：不需要修改");
                }
                atomicInteger.incrementAndGet();
            }
            dq(str, str2, j2, atomicInteger.get() + i + 1);
        }
        f i4 = f.i();
        i4.n();
        i4.l("执行完成,重启Soul后可以看见效果");
    }
}
